(function($) {
	$.fn.scroller2 = function(limit, this_li, left) {
		var $this = $(this);
		var $component = $this.find('.content');
		var $ul = $component.find('ul');
		var $lis = $ul.find('li');
		
		var width = parseInt($lis.eq(0).width(), 10) + parseInt($lis.eq(0).css('marginRight'), 10);
		var length = $lis.length;
		var max_steps = length - limit;
		
		var this_li = this_li;
		var left = left;
		var this_left = 0;
		
		var pre_button = $this.find('.pre');
		var next_button = $this.find('.next');
		var pre_button_copy = $this.find('.pre_copy');
		var next_button_copy = $this.find('.next_copy');
		var scroll_id = 0;
		
		var init = function() {
			$component.css({position:'relative', 'overflow':'hidden'});
			$ul.css({width:width * length + 'px', position:'absolute'});
			
			pre_button.click(function(){
				to_right();
				this_li--;
				if (this_li == max_steps - 1) {
					next_button.show();
					next_button_copy.hide();					
				}
				if (this_li <= 0) {
					pre_button.hide();
					pre_button_copy.show();
				}
				return false;
			});
			
			next_button.click(function(){
				to_left();
				this_li++;
				if (this_li == 1) {
					pre_button.show();
					pre_button_copy.hide();
				}
				if (this_li >= max_steps) {
					next_button.hide();
					next_button_copy.show();
				}
				return false;
			});
		}
		
		var to_left = function() {
			var step = 20;
			if (this_left < width) {
				if (this_left + step > width) {
					step = width - this_left;
				}
				left -= step;
				this_left += step;
				$ul.css('left', left+'px');
				setTimeout(function(){to_left();}, 25);
			} else {
				this_left = 0;				
			}
		}
		var to_right = function() {
			var step = 20;
			if (this_left < width) {
				if (this_left + step > width) {
					step = width - this_left;
				}
				left += step;
				this_left += step;
				$ul.css('left', left+'px');
				setTimeout(function(){to_right();}, 25);
			} else {
				this_left = 0;				
			}
		}
		init();
	}
	
})(jQuery);